package com.example.practice.activity;

import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.practice.R;
import com.example.practice.adapter.PlayHistoryAdapterYl;
import com.example.practice.bean.VideoBeanYl;
import com.example.practice.utils.DBUtils;
import com.example.practice.utils.SharedpreferencesUtils;

import java.util.ArrayList;
import java.util.List;

public class ylPlayHistoryActivity extends AppCompatActivity {
    private TextView tv_main_title,tv_back, tv_none;
    private RelativeLayout rl_title_bar;
    private ListView lv_list;
    private PlayHistoryAdapterYl adapter;
    private List<VideoBeanYl> vbl;
    private DBUtils db;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_yl_play_history);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        db=DBUtils.getInstance(this);
        vbl = new ArrayList<VideoBeanYl>();
        vbl=db.getVideoHistory(SharedpreferencesUtils.readLoginUserName(this));
        initView();
    }

    private void initView() {
        tv_main_title=findViewById(R.id.tv_title);
        tv_main_title.setText("播放记录");
        rl_title_bar=findViewById(R.id.rl_bar);
        rl_title_bar.setBackgroundColor(Color.parseColor("#30b4ff"));
        tv_back=findViewById(R.id.tv_back);
        lv_list=findViewById(R.id.yl_lv_list);
        tv_none=findViewById(R.id.yl_tv_none);
        if(vbl.size()==0){
            tv_none.setVisibility(View.VISIBLE);
        }
        adapter=new PlayHistoryAdapterYl(this);
        adapter.setData(vbl);
        lv_list.setAdapter(adapter);

        tv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ylPlayHistoryActivity.this.finish();
            }
        });
    }
}